package com.springboot.redis.demo.expire;

import com.springboot.redis.demo.RedisClient;

/**
 * 数据过期
 *
 * @author: zr
 * @date: 2021-11-17
 */
public class ExpireDemo extends RedisClient {

    public static void main(String[] args) throws InterruptedException {

        jedis.set("key", "value");
        // 设置key，5秒之后过期
        jedis.expire("key", 5);

        Thread.sleep(6000);

        String key = jedis.get("key");
        System.out.println("数据是否过期：" + ("null".equals(key) || "".equals(key) || key == null ? "是" : "否"));
    }
}
